/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.net.greenet.policybank.logic;

import cn.net.greenet.common.policy_service.PolicySupport;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.json.JsonObject;

import com.ambimmort.prserver.repository.webservice.InstanceBean;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 获取指定MessageType下的所有策略库实例
 *
 * @author liangdelin
 */
public class GetAllPolicyInstance {

    public String listInstance(String messageType) {
        //listRepositories(String type)


        List<InstanceBean> dpiInstances = PolicySupport.getInstance().getApi().listRepositories(messageType);
        Set<String> names = new HashSet<String>();
        JSONArray jsonarr = new JSONArray();
        for (InstanceBean instance : dpiInstances) {
            JSONObject jo = new JSONObject();
            jo.put("policy_warehouse_name", instance.getInstance());
            jsonarr.add(jo);
        }
        return jsonarr.toString();
    }

}
